<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test01</title>
</head>
<body>
<script type="text/javascript">
    // function add(x = 0, y = 0, z = 0) {
    //     // z = z || 0;
    //     return x + y + z;
    // }

    function add(x = 0, y = 0, ...z) {
        // z = z || 0;
        let sum = x + y;

        for (let i of z) {
            sum += i;
        }

        return sum;
    }

    console.log(add(3, 5, 10, 100));

    let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

    console.log(add(...arr));

    // let arr01 = arr.map(function (item) {
    //     return item + 100;
    // });

    let arr01 = arr.map((item) => {
        return item + 100
    });

    console.log(arr01);

    var name = "lisi";

    let stu = {
        name: "zhangsan",
        sayHello() {
            console.log(this.name);
        }
        // sayHello: function () {
        //     console.log(this.name);
        // }
        // sayHello: () => {
        //     console.log(this.name);
        //     // console.log("name");
        // }
    };

    stu.sayHello();

    stu.sayHello.call({name: 'wangwu'});


</script>
</body>
</html>